﻿//////////////////////////////////////////////////////////////////////
// Copyright© 2021 
// Author: hchlqlz
// DateTime: 2021-08-17
// Describe: 基础定义文件
//////////////////////////////////////////////////////////////////////
#include "log.h"
#include "spdlog/spdlog.h"
#include "spdlog/sinks/daily_file_sink.h"
#include "spdlog/details/registry-inl.h"

namespace XLog
{
	

	void Initialize(string projectName)
	{
		string filenameOfSystem = std::format(FILENAME_SYSTEM, projectName);
		auto logger = spdlog::daily_logger_format_mt(LOGKEY_SYSTEM, filenameOfSystem);
		logger->flush_on(spdlog::level::trace);
	}

	void LogMsg(const std::string& msg)
	{
		spdlog::get(LOGKEY_SYSTEM)->info(msg);
	}

	void XLog::LogError(const std::string& msg)
	{
		spdlog::get(LOGKEY_SYSTEM)->error(msg);
	}

	void PrintToConsole(const std::string& msg)
	{
		spdlog::info(msg);
	}

	void FileFlush()
	{
		spdlog::details::registry::instance().flush_all();
	}
}